package com.qf.flash.ui.home;

import android.content.Context;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.qf.flash.R;
import com.qf.flash.constant.FlashCodes;
import com.qf.flash.model.ScriptRoleBean;
import com.qf.flash.utils.ImageLoader;
import com.zhouwei.mzbanner.holder.MZViewHolder;

/**
 * 角色
 * 2020/3/8 17:00
 */
public class RoleBannerViewHolder implements MZViewHolder<ScriptRoleBean> {
    private ImageView iv_img;
    private TextView tvRoleName;
    private TextView tvRoleSexAge;
    private TextView tvRoleIntroduce;

    @Override
    public View createView(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_role_banner, null);
        iv_img = (ImageView) view.findViewById(R.id.iv_img);
        tvRoleIntroduce = view.findViewById(R.id.tv_desc);
        tvRoleIntroduce.setMovementMethod(ScrollingMovementMethod.getInstance());
        tvRoleName  = view.findViewById(R.id.tv_name);
        tvRoleSexAge = view.findViewById(R.id.tv_sex);
        return view;
    }

    @Override
    public void onBind(final Context context, int position, final ScriptRoleBean data) {
        //加载图片
        ImageLoader.load(context, data.getImage(), iv_img);
        tvRoleName.setText(data.getName());
        tvRoleSexAge.setText(FlashCodes.SEX_MAN.equals(data.getSex()) ? "男  " + data.getAge(): "女  " + data.getAge());
        tvRoleIntroduce.setText(data.getContent());

    }
}